package com.abigdreamer.im.client.module.talk.cinema;

import com.abigdreamer.im.client.module.messageProcess.IMessageProcess;
import com.abigdreamer.im.client.module.talk.TalkWindow;
import com.abigdreamer.im.client.module.vo.Cache;
import com.abigdreamer.im.client.util.EIMLogger;
import com.abigdreamer.im.message.BaseMessage;
import com.abigdreamer.im.message.CinemaResponseMessage;
import com.abigdreamer.im.message.MessageType;

public class CinemaResponseProcess implements IMessageProcess {

	public void processMessage(BaseMessage message) {
		EIMLogger.INFO(message);
		final CinemaResponseMessage responseMessage = (CinemaResponseMessage) message;

		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				String friendQQ = responseMessage.getSrcQQ();
				String owerQQ = responseMessage.getDestQQ();
				EIMLogger.INFO("friendQQ:" + friendQQ + " owerQQ:" + owerQQ);
				EIMLogger.INFO("cinemaResponse():" + responseMessage.getCinemaResponse());

				Cache cache = Cache.getInstance();
				TalkWindow qqTalkFrame = cache.getTalkFrame(friendQQ);
				if (!qqTalkFrame.isVisible()) {
					qqTalkFrame.setVisible(true);
				}
				if (responseMessage.getCinemaResponse() == MessageType.CinemaResponse_Accepted) {
					javax.swing.JOptionPane.showMessageDialog(qqTalkFrame, "你的好友接收了视频请求");

					// CinemaIPPort cinemaIPPortBean=new CinemaIPPort();
					//
					// cinemaIPPortBean.setGetMediaIP(responseMessage.getGetCinemaDataIP());
					// cinemaIPPortBean.setSendMediaIP(InetAddressTool.getLocalIP());
					//
					// ClientSendCinemaProcess sendCinemaProcess=new
					// ClientSendCinemaProcess(cinemaIPPortBean);
					// sendCinemaProcess.setQqTalkFrame(qqTalkFrame);
					// sendCinemaProcess.intimediaCapture();
					// // sendCinemaProcess.paly();
					// Thread thread=new Thread(sendCinemaProcess);
					// thread.start();

				} else {
					qqTalkFrame.removeSendGetFileProcessPanle();
					javax.swing.JOptionPane.showMessageDialog(qqTalkFrame, "你的好友拒绝视频请求");
				}
				EIMLogger.Error("SendCinemaDataIP:" + responseMessage.getGetCinemaDataIP());
				EIMLogger.Error("CinemaDataPort:" + responseMessage.getGetCinemaDataPort());
			}
		});
	}

}
